// 封装网络请求
import config  from "./config.js"
//  config = { url:"xxxx" }
const  http = (option = {})=>{
	// option = { url，data，method，header }
	let url = config.url+"/api/"+option.url;
	return  new  Promise((resolve,reject)=>{
		uni.request({
			url,
			data: option.data ||{},
			method: option.method ||"get",
			header: option.header||{
				"content-type":"application/json"
			},
			success(res) {
				resolve(res)
			},
			fail(err){
				reject(err)
			}
		})
	})
}

export  default http;